package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wechat.domain.CProject;
import com.ruoyi.wechat.service.ICProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/wechat/project")
public class WxProjectController extends BaseController {

    @Autowired
    private ICProjectService cProjectService;

    @GetMapping("/getInfoByCampId/{campId}")
    public AjaxResult getInfoByCampId(@PathVariable("campId") String campId) {
        if (campId == null) {
            return error("营地Id不能为空");
        }
        List<CProject> list = cProjectService.getInfoByCampId(campId);
        return success(list);
    }

    @PostMapping("/add")
    public AjaxResult add(@RequestBody CProject cProject){
        if (cProject == null) {
            return error("数据不能为空");
        }
        return toAjax(cProjectService.insertCProject(cProject));
    }

    @DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable String[] projectIds){
        return toAjax(cProjectService.deleteCProjectByProjectIds(projectIds));
    }
}
